﻿
function Person (json) {
    this.FirstName = ko.observable(json.FirstName);
    this.LastName = ko.observable(json.LastName);

    this.FullName = ko.computed(function () {
        return this.FirstName() + " " + this.LastName();
    }, this);
};

function changelanguage(locale) {
        // debugger;
        var personJSON = ko.mapping.toJSON(personVM);
        $.ajax({
            cache: false,
            type: "POST",
            url: "\\" + locale + "\\Home\\ChangeLanguage",
            contentType: 'application/json',
            dataType: "json",
            data: personJSON,
            success: function (data) {
                window.location.href = "\\" + locale + "\\Home\\Knockout";
            },
            error: function (jqXHR, textStatus, errorThrown) {
                debug;
                html = '<h1>AJAX Error</h1>' +
            '<p>The AJAX call returned the following error: ' +
                jqXHR.statusText + '.</p>';
                alert(html);
            }
        });
};
debugger;
var json = @Html.Raw(Json.Encode(Model));
var personVM = new Person(json);
ko.applyBindings(personVM);